#!/bin/bash
# -*- coding:utf-8 -*-

from pyhive import hive

#from TCLIService.ttypes import TOperationState
cursor = hive.connect(host='192.168.3.203').cursor()
cursor.execute("show databases")
print 'getDatabases:', cursor.fetchall()

'''        
with hive.connect(host='192.168.3.203') as conn:
    with conn.cursor() as cursor:
        print 'getDatabases:', cur.getDatabases()
    #print cursor.fetchall()


cursor = hive.connect('127.0.0.1:20000').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10', async=True)

status = cursor.poll().operationState
while status in (TOperationState.INITIALIZED_STATE, TOperationState.RUNNING_STATE):
    logs = cursor.fetch_logs()
    for message in logs:
        print message

    # If needed, an asynchronous query can be cancelled at any time with:
    # cursor.cancel()

    status = cursor.poll().operationState

print cursor.fetchall()
'''